package com.ruoyi.labdata.controller;

import java.util.List;

import com.ruoyi.labdata.domain.LabReservation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.labdata.domain.LabDeclarationFiling;
import com.ruoyi.labdata.service.ILabDeclarationFilingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 组织机构申报备案Controller
 * 
 * @author lzlong
 * @date 2022-05-04
 */
@RestController
@RequestMapping("/labdata/declarationFiling")
public class LabDeclarationFilingController extends BaseController
{
    @Autowired
    private ILabDeclarationFilingService labDeclarationFilingService;

    /**
     * 查询组织机构申报备案列表
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabDeclarationFiling labDeclarationFiling)
    {
        startPage();
        List<LabDeclarationFiling> list = labDeclarationFilingService.selectLabDeclarationFilingList(labDeclarationFiling);
        return getDataTable(list);
    }

    /**
     * 导出组织机构申报备案列表
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:export')")
    @Log(title = "组织机构申报备案", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabDeclarationFiling labDeclarationFiling)
    {
        List<LabDeclarationFiling> list = labDeclarationFilingService.selectLabDeclarationFilingList(labDeclarationFiling);
        ExcelUtil<LabDeclarationFiling> util = new ExcelUtil<LabDeclarationFiling>(LabDeclarationFiling.class);
        return util.exportExcel(list, "declarationFiling");
    }

    /**
     * 获取组织机构申报备案详细信息
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:query')")
    @GetMapping(value = "/{instanceId}")
    public AjaxResult getInfo(@PathVariable("instanceId") Long instanceId)
    {
        return AjaxResult.success(labDeclarationFilingService.selectLabDeclarationFilingById(instanceId));
    }

    /**
     * 新增组织机构申报备案
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:add')")
    @Log(title = "组织机构申报备案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabDeclarationFiling labDeclarationFiling)
    {
        return toAjax(labDeclarationFilingService.insertLabDeclarationFiling(labDeclarationFiling));
    }

    /**
     * 修改组织机构申报备案
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:edit')")
    @Log(title = "组织机构申报备案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabDeclarationFiling labDeclarationFiling)
    {
        return toAjax(labDeclarationFilingService.updateLabDeclarationFiling(labDeclarationFiling));
    }

    /**
     * 删除组织机构申报备案
     */
   // @PreAuthorize("@ss.hasPermi('labdata:declarationFiling:remove')")
    @Log(title = "组织机构申报备案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{instanceIds}")
    public AjaxResult remove(@PathVariable Long[] instanceIds)
    {
        return toAjax(labDeclarationFilingService.deleteLabDeclarationFilingByIds(instanceIds));
    }

    @Log(title = "提交申报备案流程", businessType = BusinessType.UPDATE)
    @PostMapping("/commit")
    public AjaxResult commit(@RequestBody LabDeclarationFiling labDeclarationFiling) {
        return AjaxResult.success(labDeclarationFilingService.commitLabDeclarationFiling(labDeclarationFiling));
    }
}
